package com.gxa.xly2024.service.impl;

import com.gxa.xly2024.mapper.PurchaseMapper;
import com.gxa.xly2024.pojo.Purchase;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.HashMap;

import java.util.List;
import java.util.Map;



@Service
public class PurchaseServiceImpl {


    @Resource
    private PurchaseMapper purchaseMapper;


    public Map<String, Object> selectPurchase() {
        List<Purchase> purchase = this.purchaseMapper.selectPurchase();
        Map<String, Object> map = new HashMap<>();
        map.put("code", 0);//查询layui默认0为正确
        map.put("msg", "查询id成功");
        map.put("data", purchase);
        return map;
    }


    public Map<String, Object> insert(Purchase purchase) {
        this.purchaseMapper.insert(purchase);
        Map<String, Object> map = new HashMap<>();
        map.put("code", 200);
        map.put("msg", "新增用户成功");
        map.put("data", purchase);
        return map;
    }

    public Map<String, Object> updateById(Purchase purchase) {
        this.purchaseMapper.updateById(purchase);
        Map<String, Object> map = new HashMap<>();
        map.put("code", 200);
        map.put("msg", "更新用户成功");
        map.put("data", purchase);
        return map;
    }

    public Map<String, Object> deleteById(Integer id) {
        this.purchaseMapper.deleteById(id);
        Map<String, Object> map = new HashMap<>();
        map.put("code", 200);
        map.put("msg", "删除用户成功");
        map.put("id", id);
        return map;
    }
}
